/**
 * 新图鉴界面
 */
class NewTujianUI extends UIBase{
    private img_light:eui.Image;
    private img_icon:eui.Image;
    private btn_share:eui.Group;
    private btn_jump:eui.Label;

    private fishData:Object;

	public constructor(data?) {
        let fish = FishTpl.instance().getDataById(data['NextTujian']);
		super('NewTujian', data);
        this.fishData = fish;
	}

	public init()
	{
        this.width = GlobalManager.instance().curWidth();
        this.height = GlobalManager.instance().curHeight();

        this.img_icon.source = this.fishData['icon'];
        this.img_icon.horizontalCenter = this.img_icon.verticalCenter = 0;
	}

    public refresh(data)
    {
        this.fishData = data;
        this.init();
    }

	public addEvent(){
		super.addEvent();
        this.btn_jump.addEventListener(egret.TouchEvent.TOUCH_TAP,this.JumpHandle, this);
        this.btn_share.addEventListener(egret.TouchEvent.TOUCH_TAP,this.shareHandle, this);
	}

    //跳过处理
    protected JumpHandle(e?)
    {
        if(e)
        {
            EffectUtil.instance().playBtnEffect(this.btn_jump);
        }
        let NextTujian = TujianCache.instance().NextTujian;
        if(NextTujian)
        {
            let fish = FishTpl.instance().getDataById(NextTujian);
            this.refresh(fish);
        }
        else
        {
            this.remove(4);
        }
    }

    //分享处理
    protected shareHandle()
    {
        EffectUtil.instance().playBtnEffect(this.btn_share);
        SharePrase.instance().requestOneAdvertisement({type:ShareId.share});
        this.JumpHandle();
    }

	public removeEvent(){
		super.removeEvent();
        this.btn_jump.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.JumpHandle, this);
        this.btn_share.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.shareHandle, this);
	}

	public clear(){
		super.clear();
        this.fishData = null;
        this.img_icon = null;
        this.img_light = null;
	}
}